# Copyright 2018- The Pixie Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("//bazel:pl_build_system.bzl", "pl_go_test")

go_library(
    name = "controllers",
    srcs = [
        "server.go",
        "utils.go",
    ],
    importpath = "px.dev/pixie/src/cloud/plugin/controllers",
    visibility = ["//visibility:public"],
    deps = [
        "//src/api/proto/uuidpb:uuid_pl_go_proto",
        "//src/cloud/cron_script/cronscriptpb:service_pl_go_proto",
        "//src/cloud/plugin/pluginpb:service_pl_go_proto",
        "//src/shared/scripts",
        "//src/shared/services/authcontext",
        "//src/shared/services/events",
        "//src/utils",
        "@com_github_gofrs_uuid//:uuid",
        "@com_github_gogo_protobuf//types",
        "@com_github_jmoiron_sqlx//:sqlx",
        "@com_github_segmentio_analytics_go_v3//:analytics-go",
        "@com_github_sirupsen_logrus//:logrus",
        "@in_gopkg_yaml_v2//:yaml_v2",
        "@org_golang_google_grpc//codes",
        "@org_golang_google_grpc//metadata",
        "@org_golang_google_grpc//status",
    ],
)

pl_go_test(
    name = "controllers_test",
    srcs = ["server_test.go"],
    deps = [
        ":controllers",
        "//src/api/proto/uuidpb:uuid_pl_go_proto",
        "//src/cloud/cron_script/cronscriptpb:service_pl_go_proto",
        "//src/cloud/cron_script/cronscriptpb/mock",
        "//src/cloud/plugin/pluginpb:service_pl_go_proto",
        "//src/cloud/plugin/schema",
        "//src/shared/scripts",
        "//src/shared/services/authcontext",
        "//src/shared/services/pgtest",
        "//src/shared/services/utils",
        "//src/utils",
        "@com_github_gofrs_uuid//:uuid",
        "@com_github_gogo_protobuf//types",
        "@com_github_golang_migrate_migrate//source/go_bindata",
        "@com_github_golang_mock//gomock",
        "@com_github_jmoiron_sqlx//:sqlx",
        "@com_github_spf13_viper//:viper",
        "@com_github_stretchr_testify//assert",
        "@com_github_stretchr_testify//require",
        "@in_gopkg_yaml_v2//:yaml_v2",
    ],
)
